Number Of Units Per Nationality

Find the number of apartments per nationality that are owned by people under 30 years old. Output the nationality along with the number of apartments. Sort records by the apartments count in descending order.

table name: airbnb_hosts


table name:airbnb_units

Solution:
select  a.nationality,count(distinct u.unit_id) from airbnb as a
 join airbnb_units as u 
on a.host_id = u.host_id
where age <30 and unit_type='Apartment'
group by a.nationality
order by count(distinct u.unit_id)

Comments (0)